<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript" charset="utf-8">
	var ctrlTree;
	var layoutindex = 0;
	$(function() {

		ctrlTree = $('#ctrlTree')
				.tree(
						{
							//url : '${pageContext.request.contextPath}/main/menuAction!doNotNeedSession_treeUserMenu.action',
							url: 'data/tree_data.json',
							lines : true,
							onClick : function(node) {
								//addTab(node);
								$(this).tree('toggle', node.target);
								if (node.attributes.url) {
									addTab(node);
								}
							},
							onDblClick : function(node) {
								if (node.state == 'closed') {
									$(this).tree('expand', node.target);
								} else {
									$(this).tree('collapse', node.target);
								}
							},
							onLoadSuccess : function(node, data) {
								
								if (data != null && data.length > 0
										&& layoutindex == 0)//展开第一层节点
								{
									layoutindex = 1;
									var node = data[0];
									expandS();

								}
							}
						});

		function expandS() {
			var node = ctrlTree.tree('getSelected');
			if (node) {
				ctrlTree.tree('expandAll', node.target);
			} else {
				ctrlTree.tree('expandAll');
			}
		}
	
		$('#tt2').tree({
                //url: 'data/tree_data.json',
                onClick: function(node) {
                    $(this).tree('toggle', node.target);
                   
                    if (node.attributes.url) {
						$("#download").attr("src",node.attributes.url);
					}
                },
		onLoadSuccess:function(node,data)
		{
			if(data!=null && data.length>0)
			{
			  var node=data[0];
			 expandS();
			}
		}

            });
	}

	);
	
		/*刷新左侧导航*/
		function refreshTree(){
					ctrlTree.tree('reload');
						layoutindex=0;
						
						
		}
	
	
	
</script>
<div class="easyui-accordion" data-options="fit:true,border:false">
	<div title="系统菜单"
		data-options="isonCls:'icon-save',tools : [ {
				iconCls : 'icon-reload',
				handler : function() {
					refreshTree();
				}
			}, {
				iconCls : 'icon-redo',
				handler : function() {
					var node = ctrlTree.tree('getSelected');
					if (node) {
						ctrlTree.tree('expandAll', node.target);
					} else {
						ctrlTree.tree('expandAll');
					}
				}
			}, {
				iconCls : 'icon-undo',
				handler : function() {
					var node = ctrlTree.tree('getSelected');
					if (node) {
						ctrlTree.tree('collapseAll', node.target);
					} else {
						ctrlTree.tree('collapseAll');
					}
				}
			} ]">
		<ul id="ctrlTree" style="margin-top: 5px;"></ul>
	</div>
	<div title="帮助菜单">
		<ul id="tt2"></ul>
	</div>	
</div>

<iframe id="download" src="" style="display:none"></iframe>